tree grammar Hobbes2008TIRBuilder;

options {
 	language = Java;
   	tokenVocab = Hobbes2008;
    	ASTLabelType = CommonTree;
}

@header {
package edu.calvin.djs32.cs214.interpreters.frontend;
import edu.calvin.cs214.hobbes2008.*;
}

@members { 
  protected void mismatch(IntStream input, int ttype, BitSet follow) 
    throws RecognitionException { 
    throw new MismatchedTokenException(ttype, input); 
  } 
  public void recoverFromMismatchedSet(IntStream input, RecognitionException e, BitSet follow) 
    throws RecognitionException { 
    throw e; 
  } 
} 
@rulecatch { 
  catch (RecognitionException e) { 
    throw e; 
  } 
} 

expression returns [HobbesTIR tir]
@init {
        List expressions = new ArrayList<HobbesTIR>();
}
        : INTEGER { $tir = new IntegerTIR(Integer.decode($INTEGER.getText())); }
        | STRING { $tir = new StringTIR($STRING.getText().substring(1, ($STRING.getText().length()-1))); }
        | ^(TUPLE ( ex=expression { expressions.add(ex); } )*) { $tir = new TupleTIR(expressions); }
        ;
